<?php
$userService = new UserService();
switch ($action) {
	case "changeP":
		if(isset($_SESSION['user']))
	    {
	    	$userService = new UserService();
	        $id = $_SESSION['user']['ID'];
			$oldpass = Tool::md5_base64($_POST['oldPass']);
			$newpass = $_POST['newpass'];
			$confirmPass = $_POST['newpassconf'];
			$user = $userService->findByOid($context, $result, $id);
			if($newpass == $confirmPass && $user->getPass() == $oldpass)
			{
				$userService->changePass($context, $result, $newpass,$id);
				session_destroy();
				echo "<script>alert('Change Password Success!!!');window.location='index.php?func=login';</script>";
				die();	
			}	
			else echo "<script>alert('Change Password Fail!!!');window.location='index.php?func=dash';</script>";	
	    }
	    else 
	    	header("Location:index.php?func=login");		

	break;
	default:
		echo "khong co tinh nang nay";
	break;
}		
?>